package com.qf.controller;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.qf.pojo.User;
import org.elasticsearch.client.RestHighLevelClient;//原生 的类  7.6.2
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;//将原生的类封装成Spring框架的类
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

import javax.sql.DataSource;

/**
 * @author lixu
 */
@Controller
@RequestMapping("/gp14")
public class Gp14Controller {

    @Autowired
    private DataSource dS;
    @Autowired
    private JedisPool jedisPool;
    @Autowired
    private User user;

    //自定义New
    //private ObjectMapper objectMapper = new ObjectMapper();
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private ElasticsearchRestTemplate elasticsearchRestTemplate;
    @Autowired
    private RestHighLevelClient restHighLevelClient;


    /**
     * 进入欢迎 页面
     */
    @GetMapping("/index")
    public String index(Model model) throws Exception{

        System.out.println(dS.getConnection());

        Jedis jedis = jedisPool.getResource();
        jedis.set("key","value");

        model.addAttribute("haha","hehe");
        return "gp14";
    }
}
